import {deflateRawSync} from "zlib";

export default {
    getSecret(platform,hash,type){
        let s = Buffer.from("624868746c", 'hex').toString()
        s = s.replace(s.substr(-1), '')
        s = Buffer.from(s, 'base64').toString()
        let v = '0.17.0'.split('.').map(n => n.length < 3 ? n.padStart(3, '0') : n).join('');
        let url=`http://ts.tempmusic.tk/url/${platform}/${hash}/${type}`;
        let regx = /(?:\d\w)+/g;
        return  !s || `${deflateRawSync(Buffer.from(JSON.stringify(`${url}${v}`.match(regx), null, 1).concat(v)).toString('base64')).toString('hex')}&${parseInt(v)}`;
    }
}